package com.kai.steering.data.service.entity.domainObject;

import cn.hutool.core.bean.BeanUtil;
import com.kai.steering.data.service.entity.dto.CaretakerQueryDTO;
import com.kai.steering.data.service.entity.po.Caretaker;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Date;

import lombok.*;

import java.io.Serializable;

/**
 * <pre>
 * 管理员 Do对象
 * </pre>
 *
 * @author kai
 * @date 2022-02-23
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "CaretakerDO对象", description = "管理员业务实体")
public class CaretakerDO implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "账号")
    private String caretakerId;
    @ApiModelProperty(value = "密码")
    private String password;
    @ApiModelProperty(value = "用户名")
    private String caretakerName;
    @ApiModelProperty(value = "用户简介")
    private String introduce;
    @ApiModelProperty(value = "用户生日期")
    private Date birthday;
    @ApiModelProperty(value = "管理员id")
    private String founder;
    @ApiModelProperty(value = "创建日期")
    private Date creationDatetime;
    @ApiModelProperty(value = "用户电话")
    private String phone;
    @ApiModelProperty(value = "用户地址")
    private String address;
    @ApiModelProperty(value = "存在0删除1")
    private Integer usable;
    @ApiModelProperty(value = "删除日期")
    private Date deleteDatetime;

    public CaretakerDO(Caretaker caretaker){
        convertCaretakerDO(caretaker);
    }

    public CaretakerDO(CaretakerQueryDTO caretakerQueryDTO) {
        this.caretakerId=caretakerQueryDTO.getCaretakerId();
        this.password=caretakerQueryDTO.getPassword();
        this.caretakerName=caretakerQueryDTO.getCaretakerName();
        this.introduce=caretakerQueryDTO.getIntroduce();
        this.birthday=caretakerQueryDTO.getBirthday();
        this.founder=null;
        this.creationDatetime=null;
        this.phone=caretakerQueryDTO.getPhone();
        this.address=caretakerQueryDTO.getAddress();

        this.deleteDatetime=null;


    }

    public CaretakerDO convertCaretakerDO(Caretaker caretaker) {
        this.caretakerId=caretaker.getCaretakerId();
        this.password=caretaker.getPassword();
        this.caretakerName=caretaker.getCaretakerName();
        this.introduce=caretaker.getIntroduce();
        this.birthday=caretaker.getBirthday();
        this.founder=caretaker.getFounder();
        this.creationDatetime=getCreationDatetime();
        this.phone=caretaker.getPhone();
        this.address=caretaker.getAddress();
        this.usable=getUsable();
        this.deleteDatetime=getDeleteDatetime();
        return this;
    }
}